package com.yingside.io.io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class TestIOCharacterCopy {
    public static void main(String[] args) {
        FileReader fileReader = null;
        FileWriter fileWriter = null;

        try {
            fileReader = new FileReader("Test2.java");
            fileWriter = new FileWriter("images/TestJFram.java");
            char [] cs = new char[1024];

            int c = 0;

            while((c = fileReader.read(cs)) != -1){
                String str = new String(cs,0,c);
                fileWriter.write(str);
            }

            //fileWriter.flush();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
